/*  Game/Army Editor for yALB - Yet Another List Builder (roster Editor for Wargames/tabletop games).
    Copyright (C) 2008-2012  Daniel Ricardo Castro Alvarado

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.*/

#ifndef OPTIONWIDGET_H
#define OPTIONWIDGET_H

#include <QWidget>
#include <QHash>

#include "collections/optioncollection.h"

//#include "actionwidget.h"
#include "propertyform.h"

class CategorizerModel;
class ItemSelector;

namespace Ui {
    class OptionWidget;
}

class OptionWidget : public QWidget
{
    Q_OBJECT

public:
    OptionWidget(OptionCollection *_options, CategorizerModel *_optionModel, ItemSelector& _itemSelector,
                          QWidget *parent = 0);
    ~OptionWidget();

    void clearOptionForm();

public slots:
    void addProperty(const GameProperty& property, const QString &key);
    void updateProperty(const QString& oldKey, const GameProperty& newProperty,
                         const QString& newKey);
    void removeProperty(const QString& key);

    /*void addColumn(const Column &column, const QString &key);
    void updateColumn(const QString& oldKey, const Column& newColumn,
                         const QString& newKey);
    void removeColumn(const QString& key);*/

protected:
    void changeEvent(QEvent *event);

private slots:
    void currentItemChanged(const QModelIndex& current, const QModelIndex& previous);
    void on_optAdd_clicked();
    void on_optUpdate_clicked();
    void on_optDelete_clicked();
    void on_optClone_clicked();
    void on_optSetPropertiesButton_clicked();

private:
    Ui::OptionWidget *ui;

    OptionCollection *options;
    CategorizerModel *optionModel;

    PropertyForm propertyForm;
};

inline void OptionWidget::addProperty(const GameProperty &property, const QString &key) {
    propertyForm.addProperty(property, key);
}

inline void OptionWidget::updateProperty(const QString &oldKey, const GameProperty &newProperty,
                                         const QString &newKey) {
    propertyForm.updateProperty(oldKey, newProperty, newKey);
}

inline void OptionWidget::removeProperty(const QString &key) {
    propertyForm.removeProperty(key);
}

/*inline void OptionWidget::addColumn(const Column &column, const QString &key) {
    actionBox.addColumn(column, key);
}

inline void OptionWidget::updateColumn(const QString &oldKey, const Column &newColumn,
                                       const QString &newKey) {
    actionBox.updateColumn(oldKey, newColumn, newKey);
}

inline void OptionWidget::removeColumn(const QString &key) {
    actionBox.removeColumn(key);
}*/

#endif // OPTIONWIDGET_H
